//
//  BaseNavigationController.m
//  ChineseCollegeStudentsNetwork
//
//  Created by 魏苏扬 on 2018/8/8.
//  Copyright © 2018年 刘喆. All rights reserved.
//

#import "BaseNavigationController.h"
#import "UserCenterViewController.h"

@interface BaseNavigationController ()<UINavigationControllerDelegate>

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    
    // Do any additional setup after loading the view.
    UINavigationBar *bar = [UINavigationBar appearance];
    //设置显示的颜色
    bar.barTintColor = [UIColor whiteColor];//UIColorFromRGBHex(0x5659e0);
    bar.translucent = NO;
    //设置字体颜色
    bar.tintColor = [UIColor blackColor];
    [bar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:17 weight:UIFontWeightMedium]}];
}

#pragma mark- UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    BaseViewController *vc = (BaseViewController *)viewController;
    if ([vc respondsToSelector:@selector(needHideNavigationBar)]) {
        [self setNavigationBarHidden:vc.needHideNavigationBar animated:YES];
    }else{
        [self setNavigationBarHidden:YES animated:YES];
    }
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.childViewControllers.count > 0) {
        if(![viewController isKindOfClass:[UserCenterViewController class]]) {
            viewController.hidesBottomBarWhenPushed = YES;
        }
    }
    [super pushViewController:viewController animated:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
